package hbase;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.*;
import org.apache.hadoop.hbase.util.Bytes;
import servlet.Deletes;


import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class HbaseUtilD  extends Deletes {


    public String Delete(String rowkey) throws IOException {
        Configuration conf= HBaseConfiguration.create();
        conf.set("hbase.zookeeper.quorum","192.168.116.11");
        Connection connection = ConnectionFactory.createConnection(conf);
//        Table table = connection.getTable(TableName.valueOf("goodsmessage"));
//        List list = new ArrayList();
//        Delete delete = null;
//
//        try {
//            //创建删除对象
//            delete = new Delete(Bytes.toBytes(rowkey));
//        }catch (Exception e){
//            e.printStackTrace();
//        }
//
//        list.add(delete);
//        //执行删除操作
//        table.delete(list);
        HTable table = new HTable(conf, "goodsmessage");
       try {
           Delete d = new Delete(Bytes.toBytes(rowkey));
           table.delete(d);
           table.close();
       }catch (Exception e)
       {
           e.printStackTrace();

       }

//        org.apache.hadoop.hbase.client.Delete delete=new org.apache.hadoop.hbase.client.Delete(dln.getBytes());
//        table.delete(delete);

        return "删除成功";

    }

}
